package de.freudenreichdesign.webshop.controller;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import de.freudenreichdesign.webshop.model.Order;
import de.freudenreichdesign.webshop.service.AccountService;

@Controller
@RequestMapping ("/showOrderList.html")
public class OrderListController{

	@RequestMapping(method=RequestMethod.GET)
	public String handleRequest(ModelMap modelMap) {
		List<Object> listOfOrdersAsObject = AccountService.getInstance().getOrderListFromCustomer(1);
		Set<Order> listOfOrders = new HashSet<Order>();
		for (Object order : listOfOrdersAsObject) {
			listOfOrders.add((Order)order);
		}
		modelMap.addAttribute("orderList", listOfOrders);
		return "orderListView";
	}

}
